/************************************************************
  GSM Modem SIM900 driver (external interface)
  Ref.
    http://www.mt-system.ru/documents/sim900_atc_v1.03.pdf
    http://www.mt-system.ru/documents/an_sim900_ip_application%20note_v1.00_draft.pdf
************************************************************/

#ifndef GSM_H_
#define GSM_H_

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

//#include <ctl.h>

//#include "../led.h"
#include "modem.h"
#include "ff.h"
#include "utils.h"

#include "json.h"

/*
typedef struct {
  char month;
  char day;
  int  year;
  char hour;
  char minute;
  char second;
} datetime_t;
*/

char* path;
typedef enum
{
  GSM_SIM1 = 0,
  GSM_SIM2
} GSM_SIM_t;




#ifdef __cplusplus
extern "C" {
#endif
  
/* Return modem status */
GSM_STATUS_t gsm_status();

/* Power on GSM modem and initialize GSM network. */
GSM_STATUS_t gsm_enable(char* apn, GSM_SIM_t sim, int baud);

/* Connect modem to a specified host and port */
GSM_STATUS_t gsm_connect(char* host, unsigned int port);

GSM_STATUS_t GSM_TRANSF_DATA(int ERROR_GS);

/* Disconnect modem from a host */
GSM_STATUS_t gsm_disconnect();

/* Power GSM off */
GSM_STATUS_t gsm_disable();

/* Transmit RTEA encrypted data to a server */
GSM_STATUS_t gsm_transmit_json(char* request, unsigned int length);


/* Transmit raw data to a server */
GSM_STATUS_t gsm_http_download(char* host, char* path, char* filename, unsigned int* crc32, unsigned long timeout_ms);
void gsm_status_set(GSM_STATUS_t s);
int GET_TEMP();




#ifdef __cplusplus
}
#endif
#endif /* GSM_H_ */
